from django.template import Library
from django.utils.safestring import mark_safe
from pagemagic.spares.models import Text

register = Library()

@register.simple_tag
def spare_text(name, default=None):
    if default is None:
        default = u'<span style="color:red">`%s`</span>' % name
    return mark_safe(Text.get(name) or default)
